﻿using System;
using System.Windows.Forms;

namespace Relocation.Com
{
	/// <summary>
	/// 显示统一格式的信息提示框
	/// </summary>
	public static class MyMessagebox
	{
		/// <summary>
		/// 显示普通消息
		/// </summary>
		/// <param name="str">消息内容</param>
		/// <returns>DialogResult</returns>
		public static DialogResult Show(string str)
		{
			return MessageBox.Show(str, "房屋拆迁安置管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
		}

		/// <summary>
		/// 显示确认对话框
		/// </summary>
		/// <param name="message">消息内容</param>
		/// <returns>yes或no按钮</returns>
		public static DialogResult Confirm(string message)
		{
			return MessageBox.Show(message, "房屋拆迁安置管理系统", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
		}

		/// <summary>
		/// 显示错误消息
		/// </summary>
		/// <param name="message">消息内容</param>
		/// <returns>DialogResult</returns>
		public static DialogResult Error(string message)
		{
			return MessageBox.Show("系统发现错误，请联系管理人员。\n" + message, "房屋拆迁安置管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}

		public static DialogResult Error(Exception exception)
		{
			string message = "";
			if (exception.InnerException != null)
			{
				message = exception.InnerException.Message;
			} else
			{
				message = exception.Message;
			}
			return MessageBox.Show("系统发现错误，请联系管理人员。\n" + message, "房屋拆迁安置管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
	}
}
